package com.marktotop.learntwo.service;

import com.marktotop.learntwo.dao.BookDao;
import com.marktotop.learntwo.dao.UserDao;

/**
 * @author WXLD
 * @data 2021/4/17 - 14:38
 */
public class UserServiceImpl implements UserService{

    private UserDao userDao;
    // 注入bookDao
    private BookDao bookDao;

    private int num;

//    private int num;
//    private String value;

//    /**
//     * 使用构造器注入：提供属性构造
//     * @param userDao
//     * @param num
//     * @param value
//     */
//    public UserServiceImpl(UserDao userDao, int num, String value) {
//        this.userDao = userDao;
//        this.num = num;
//        this.value = value;
//    }

//    /**
//     * set注入：提供属性的set方法
//     */
//    public void setUserDao(UserDao userDao) {
//        this.userDao = userDao;
//    }
//    public void setNum(int num) {
//        this.num = num;
//    }
//    public void setValue(String value) {
//        this.value = value;
//    }


    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }
    public void setBookDao(BookDao bookDao) {
        this.bookDao = bookDao;
    }

    @Override
    public void save() {
        // 使用注入的资源
//        System.out.println("userService run......"+"num:"+num+",value:"+value);
        System.out.println("userService run......");
        userDao.userMapper();
        bookDao.save();
    }

    public void setNum(int num) {
        this.num = num;
    }

    public int getNum() {
        return num;
    }
}
